<?php
/**
 * 游戏服务器配置信息抽象类
 *
 * @author xiemaomao@iwgame.com
 * @copyright Copyright (c) 2009 Green Shore (http://www.iwgame.com)
 * @version $Id: Abstract.php 1082 2011-12-09 09:27:48Z mmxie $
 */
abstract class IG_Product_Config_Abstract
{
    protected $_data = array(
        'name'      => null,
        'title'     => null,
        'data'      => array(),
        'children'  => array(),
    );

    public function __construct(array $data = null)
    {
        if ($data) {
            $this->_data = $data;
        }
    }

    public function __get($var)
    {
        return $this->{'get' . ucfirst($var)}();
    }

    public function getName()
    {
        return $this->_data['name'];
    }

    public function getTitle()
    {
        return $this->_data['title'];
    }

    public function getData($key = null)
    {
        if ($key !== null) {
            if (isset($this->_data['data'][$key])) {
                return $this->_data['data'][$key];
            } else {
                return null;
            }
        }
        return $this->_data['data'];
    }

    public function getChildren()
    {
        return $this->_data['children'];
    }
}